Skip to content

Tutorial - #1439

Merged
Yurlungur merged 29 commits into
developfrom
jmm/turorial
Sep 11, 2026
Merged

Yurlungur merged 29 commits into
developfrom
jmm/turorial

Conversation

@Yurlungur

@Yurlungur Yurlungur commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

PR Summary

In preparation for the Parthenon workshops coming up I finally sat down and wrote a tutorial for how to use parthenon. In the end I did not use gen AI as I wanted to convey very specifically the story I wanted to convey. I also made some minor tweaks to Parthenon guts and scripts to make sure the tutorial worked as intended.

I can't include the project I wrote that the tutorial walks through, as it would be a bit recursive. But if someone else wanted to create it in the parthenon namespace and follow the tutorial so we had a complete version, that wouldn't be unwelcome. That would be a good test my instructions work for someone else.

PR Checklist

  • Code passes cpplint
  • New features are documented.
  • Adds a test for any bugs fixed. Adds tests for new features.
  • Code is formatted
  • Changes are summarized in CHANGELOG.md
  • Change is breaking (API, behavior, ...)
    • Change is additionally added to CHANGELOG.md in the breaking section
    • PR is marked as breaking
    • Short summary API changes at the top of the PR (plus optionally with an automated update/fix script)
  • CI has been triggered on Darwin for performance regression tests.
  • Docs build
  • Any contribution that was created or modified with the assistance of generative AI is disclosed here and in code following the guidelines
  • (@lanl.gov employees) Update copyright on changed files

@Yurlungur Yurlungur self-assigned this Aug 24, 2026
@Yurlungur Yurlungur added the documentation Improvements or additions to documentation label Aug 24, 2026
@Yurlungur

Copy link
Copy Markdown
Collaborator Author

@par-hermes format

@@ -1,4 +1,4 @@
.. par_for:
.. _par_for:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a typo.

plt.colorbar(
pm, label=colorbar, fontsize=fontsize, fraction=0.02, pad=0.04, ax=p
)
plt.colorbar(pm, label=colorbar, fraction=0.02, pad=0.04, ax=p)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

matplotlib api changed. fontsize can't go here anymore.

Comment thread scripts/python/packages/parthenon_tools/parthenon_tools/movie2d.py
Comment thread src/interface/swarm_device_context.hpp
@Yurlungur Yurlungur mentioned this pull request Aug 24, 2026
12 tasks
@Yurlungur

Copy link
Copy Markdown
Collaborator Author

@Yurlungur
Yurlungur enabled auto-merge August 24, 2026 16:29
Comment thread doc/sphinx/src/tutorial.rst Outdated
Comment thread doc/sphinx/src/tutorial.rst Outdated
@Yurlungur Yurlungur mentioned this pull request Aug 24, 2026
13 tasks
@Yurlungur

Copy link
Copy Markdown
Collaborator Author

@pgrete @c-prather please re-review. It should be updated with your suggestions and the issues we found in the live run.

@c-prather c-prather left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left the changes I had to (one I wanted to) make when updating the compile-able example, and some wording things when going through the text again.

Otherwise LGTM, really excellent stuff and I'm glad we finally have this. Bravo.

Comment thread doc/sphinx/src/tutorial.rst Outdated
Comment thread doc/sphinx/src/tutorial.rst Outdated
Comment thread doc/sphinx/src/tutorial.rst Outdated
Comment thread doc/sphinx/src/tutorial.rst Outdated
Comment thread doc/sphinx/src/tutorial.rst Outdated
Comment thread doc/sphinx/src/tutorial.rst
Comment thread doc/sphinx/src/tutorial.rst Outdated
Comment thread scripts/python/packages/parthenon_tools/parthenon_tools/movie2d.py
Comment thread src/interface/swarm_device_context.hpp

@lroberts36 lroberts36 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

Comment thread doc/sphinx/src/tutorial.rst
Yurlungur and others added 9 commits September 2, 2026 16:13
Co-authored-by: Cora Prather <cprather@radimant.org>
Co-authored-by: Cora Prather <cprather@radimant.org>
Co-authored-by: Cora Prather <cprather@radimant.org>
Co-authored-by: Cora Prather <cprather@radimant.org>
Co-authored-by: Cora Prather <cprather@radimant.org>
@Yurlungur
Yurlungur disabled auto-merge September 2, 2026 20:21
@Yurlungur
Yurlungur enabled auto-merge September 2, 2026 20:21
@Yurlungur

Copy link
Copy Markdown
Collaborator Author

@pgrete is something wrong with the CI machine? Jobs are failing when trying to fetch openpmd from github.

@pgrete

pgrete commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

@pgrete is something wrong with the CI machine? Jobs are failing when trying to fetch openpmd from github.

CI machine was restarted and I had to manually fire up the runners again.
They should be available again as of three ours ago.

@pgrete pgrete left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Great writeup! This was truly overdue and my impression is that it was well received during the user meeting.

mkdir src
touch CMakeLists.txt
git submodule add git@github.com:parthenon-hpc-lab/parthenon.git external/parthenon
git add external parthenon

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
git add external parthenon
git add external/parthenon

Comment on lines +112 to +113
Parthenon also has a Spack package (``spackage``). You can see
details in our :ref:`build doc <building>`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh, this reminds me that I should update the spack package..
probably even more relevant now given that RIOT is available

project(ellipse LANGUAGES C CXX)
# We require C++20
set(CMAKE_CXX_STANDARD 20)
# A useful command for debugging

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# A useful command for debugging
# A useful command for debugging as it creates a `compile_commands.json` in your build
# directory containing the exact commands to build the code with a given config.
# Moreover, that file can also be parsed by IDEs for cross referencing.

Comment on lines +339 to +340
Anatomy of a Task
^^^^^^^^^^^^^^^^^^^

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Anatomy of a Task
^^^^^^^^^^^^^^^^^^^
Anatomy of a Task
^^^^^^^^^^^^^^^^^

Comment on lines +440 to +441
const Real r = std::sqrt(x * x + y * y);
const Real th = std::atan2(y, x);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const Real r = std::sqrt(x * x + y * y);
const Real th = std::atan2(y, x);
const Real r = Kokkos::sqrt(x * x + y * y);
const Real th = Kokkos::atan2(y, x);

Comment on lines +638 to +639
const Real dx = std::min(std::abs(x - xmin), std::abs(xmax - x));
const Real dy = std::min(std::abs(y - ymin), std::abs(ymax - y));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const Real dx = std::min(std::abs(x - xmin), std::abs(xmax - x));
const Real dy = std::min(std::abs(y - ymin), std::abs(ymax - y));
const Real dx = Kokkos::min(std::abs(x - xmin), Kokkos::abs(xmax - x));
const Real dy = Kokkos::min(std::abs(y - ymin), Kokkos::abs(ymax - y));

// speed times dt, which is r * omega * dt, which must be
// less than delta:
// dt <= delta / (r * omega)
ldt = std::min(ldt, delta / (std::abs(r * omega) + EPS));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ldt = std::min(ldt, delta / (std::abs(r * omega) + EPS));
ldt = Kokkos::min(ldt, delta / (Kokkos::abs(r * omega) + EPS));

This is very much a toy heuristic for a toy problem. We simply check
how far away a particle is from the boundaries of its meshblock
(including ghost cells) and don't let the particle move fast enough to
leave its current block.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
leave its current block.
leave its current block.
Note the use of Kokkos math functions. While not strictly necessary
(`std::` math work just fine on most architectures) using the Kokkos
version ensures portability for future architectures.

Comment on lines +729 to +731
const IndexRange ib = cellbounds.GetBoundsI(IndexDomain::interior);
const IndexRange jb = cellbounds.GetBoundsJ(IndexDomain::interior);
const IndexRange kb = cellbounds.GetBoundsK(IndexDomain::interior);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rotate went over entire, which I assumed to be done because there's no ghost comm.
Is is then fine/consistent to just seed interior?
Probably yes, because on init we communicate Independent no matter what, don't we?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do. But I think you're right it's a little confusing. I'll change it to entire.

Comment on lines +1039 to +1040
After the particle positions have been updated, they must be
communicated across the mesh, which is the role of the next set of tasks:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After the particle positions have been updated, they must be
communicated across the mesh, which is the role of the next set of tasks:
After the particle positions have been updated, the particles now residing in ghost zones must be
communicated to their respective neighboring blocks, which is the role of the next set of tasks:

@Yurlungur
Yurlungur merged commit 4a46a9e into develop Sep 11, 2026
42 of 46 checks passed
@Yurlungur
Yurlungur deleted the jmm/turorial branch September 11, 2026 05:04
@Yurlungur

Copy link
Copy Markdown
Collaborator Author

Thanks for the re-review @pgrete . I messed up and merged this before before I addressed your comments. Now in #1452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants